-- Copyright (c) 202const.NUMBER_FOUR Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--         http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

-- Description: The unit test for common interfaces.
local lu = require 'luaunit'
local test_file = require 'common'
local const = require 'test_constants'

module = {}

-- 测试基本运算符
function module.test_compare()
    -- 小于
    lu.assertEquals(test_file.compare(const.NUMBER_ONE, const.NUMBER_ONE, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_ONE, const.NUMBER_TWO, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_ONE, const.NUMBER_THREE, const.NUMBER_TWO), false)
    -- 小于等于
    lu.assertEquals(test_file.compare(const.NUMBER_TWO, const.NUMBER_ONE, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_TWO, const.NUMBER_TWO, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_TWO, const.NUMBER_THREE, const.NUMBER_TWO), false)
    -- 大于
    lu.assertEquals(test_file.compare(const.NUMBER_THREE, const.NUMBER_ONE, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_THREE, const.NUMBER_TWO, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_THREE, const.NUMBER_THREE, const.NUMBER_TWO), true)
    -- 大于等于
    lu.assertEquals(test_file.compare(const.NUMBER_FOUR, const.NUMBER_ONE, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_FOUR, const.NUMBER_TWO, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_FOUR, const.NUMBER_THREE, const.NUMBER_TWO), true)
    -- 等于
    lu.assertEquals(test_file.compare(const.NUMBER_FIVE, const.NUMBER_ONE, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_FIVE, const.NUMBER_TWO, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_FIVE, const.NUMBER_THREE, const.NUMBER_TWO), false)
    -- 不等于
    lu.assertEquals(test_file.compare(const.NUMBER_SIX, const.NUMBER_ONE, const.NUMBER_TWO), true)
    lu.assertEquals(test_file.compare(const.NUMBER_SIX, const.NUMBER_TWO, const.NUMBER_TWO), false)
    lu.assertEquals(test_file.compare(const.NUMBER_SIX, const.NUMBER_THREE, const.NUMBER_TWO), true)
end

return module